package main

import (
	"sync"
	"time"
)

func main() {
	/*	fmt.Println("main start")

		go func() {
			fmt.Println("goroutine")
		}()

		time.Sleep(1 * time.Second)

		fmt.Println("main end")*/

	//无缓冲通道演示
	c := make(chan string, 20)

	var wg sync.WaitGroup
	wg.Add(2)

	go func() {
		defer wg.Done()
		c <- `foo`
	}()

	go func() {
		defer wg.Done()

		time.Sleep(time.Second * 10)
		println(`Message: ` + <-c)
	}()

	wg.Wait()

}
